<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./vue.js"></script>
    <style>
        .active {
            border: 1px solid red;
            background: #a0ffff;
            width: 100px;
            height: 100px;
        }
        
        .text-danger {
            background: brown;
        }
    </style>
</head>

<body>
    <div id="app">
        <button @click="methodesActive()">Click Me</button>
        <!-- text-danger会覆盖前面的样式 -->
        <div v-bind:class="{active:isActive,'text-danger':true}">
            这是一个div标签
        </div>
    </div>

    <div id="demo">
        <div v-bind:class="classObject">
            emmmmmm
        </div>
    </div>
</body>
<script>
    new Vue({
        el: "#app",
        data: {
            isActive: true
        },
        methods: {
            methodesActive: function() {
                this.isActive = this.isActive ? false : true
            }
        }
    })

    let vm = new Vue({
        el: "#demo",
        data: {
            isActive: true,
            error: null,
        },
        computed: {
            classObject: function() {
                return {
                    active: this.isActive && !this.error,
                    'text-danger': this.error && this.error.type === 'fatal'
                }
            }
        }

    })
</script>

</html>